package com.wtwd.campus.dao;

import com.baomidou.mybatisplus.core.metadata.IPage;
import com.baomidou.mybatisplus.extension.plugins.pagination.Page;
import com.wtwd.campus.entity.DeviceInfo;
import com.wtwd.campus.entity.ExcelExportDeviceInfo;
import com.wtwd.campus.entity.ModifyDeviceDataVo;
import com.wtwd.campus.entity.QuerySimCardDataVo;
import org.apache.ibatis.annotations.Mapper;
import org.apache.ibatis.annotations.Param;

import java.util.HashMap;
import java.util.List;
import java.util.Map;

/**
 * @author mjy
 * @date 2021/06/09
 * @description
 */
@Mapper
public interface DeviceInfoMapper {

    List<Map<String, Object>> getDeviceIncrease(@Param("startTime") long startTime, @Param("endTime") long endTime, @Param("orgCode") String orgCode);

    List<DeviceInfo> getDeviceListByOrgCode(@Param("orgCode") String orgCode);

    IPage<Map<String,Object>> getSimCardList(@Param("data") QuerySimCardDataVo data,@Param("page") Page page);

    Integer bindDevice(@Param("stuId") Integer stuId,@Param("deviceId") Integer deviceId);

    DeviceInfo getDeviceInfoByStudentId(@Param("stuId") Integer stuId);

    Integer noBind(@Param("studentId") Integer studentId);

    List<Map<String, Object>>  getDeviceImeiAndDeviceIdByOrgCodeLikeImei(@Param("imei") String imei,@Param("orgCode") String orgCode);

    //根据sim卡号码去查询一台设备
    Integer getDeviceBySimCard(String simCard);

    //修改设备的sim卡号
    Integer modifyDeviceSimCard(@Param("data") ModifyDeviceDataVo data);

    DeviceInfo getDeviceByCondition(@Param("deviceInfo") DeviceInfo deviceInfo);

    int batchBindDevice(@Param("list") List<DeviceInfo> deviceInfos);

    IPage<Map<String, Object>> getDeviceInfoListByCondition(@Param("searchMap") HashMap<String, Object> searchMap,@Param("page") Page<Object> page);

    List<Map<String, Object>> getModelByOrgCode(@Param("orgCode") String orgCode);

    Integer deleteDeviceById(@Param("deviceId") Integer deviceId);

    Integer saveDeviceInfo(@Param("deviceInfo") DeviceInfo deviceInfo);

    List<ExcelExportDeviceInfo> ExcelExportDeviceInfo(@Param("searchMap")HashMap<String, Object> searchMap);

    Integer batchSaveDevice(@Param("list") List<DeviceInfo> list);

    Integer updateDeviceInfo(@Param("deviceInfo") DeviceInfo deviceInfo);

    DeviceInfo getDeviceInfoByDeviceId(@Param("deviceId") Integer deviceId);

    //根据imei号查询设备
    DeviceInfo getDeviceInfoByImei(String imei);

    //修改设备信息
    Integer modifyDeviceInfo(@Param("device") DeviceInfo device);

    /**
     * 查询客户设备列表
     * @param page 分页对象
     * @param imei 模糊左匹配的imei号
     * @param customerId 客户id
     * @return
     */
    IPage<Map<String,Object>> getCustomerDeviceList(@Param("page") IPage<Map<String,Object>> page,@Param("imei")String imei,@Param("customerId")Integer customerId);

    //删除一台设备的亲情号码
    Integer deleteAffectionByDeviceId(Integer deviceId);

    //删除一台设备的白名单
    Integer deleteWhiteListByDeviceId(Integer deviceId);

    //删除一台设备的课堂模式设置
    Integer deleteClassPatternByDeviceId(Integer deviceId);

    /**
     * 更新设备模式及指令序列号
     * @param imei
     * @param mode
     * @param interval
     * @param commandNumber
     * @return
     */
    int updateDeviceMode(@Param("imei")String imei,@Param("mode")Integer mode,@Param("interval")Integer interval,
                         @Param("commandNumber")String commandNumber);

    /**
     * 修改设备模式的序列号
     * @param imei
     * @param commandNumber
     * @return
     */
    int updateDeviceModeStatus(@Param("imei") String imei, @Param("commandNumber") String commandNumber);

    /**
     * 根据学生id查找设备
     * @param stuId
     * @return
     */
    DeviceInfo getDeviceInfoByStuId(Integer stuId);

    List<Map<String,Object>> getStudentPlaceByStudentId(@Param("list") List<Integer> list);

    List<Map<String,Object>> getStudentPlaceByDeviceId(@Param("list") List<Integer> list);

    Integer deleteSOSList(@Param("deviceId") Integer deviceId);

    List<String> getImeiListByDeviceIdList(@Param("list") List<Integer> list);

    Integer unbindStudentByDeviceId(@Param("deviceId") Integer deviceId);

    Integer bindDeviceAndSynchronizationOrg(@Param("stuId") Integer stuId,@Param("deviceId") Integer deviceId,@Param("orgCode") String orgCode,@Param("orgName")String orgName );

    int unBindingStudentWithDevice(@Param("stuId") Integer stuId);

    List<DeviceInfo> getDeviceInfoListByStuIdList(@Param("list") List<Integer> list);

    List<String> getImeiListByImeiList(@Param("list") List<String> list);

    int addSomeThirdPartDevice(@Param("list") List<DeviceInfo> list);

    List<Map<String,Object>> getStudentPlaceByDeviceIdAndH5UserId(@Param("list") List<Integer> list,@Param("userId") Integer userId);

    DeviceInfo getDeviceInfoByRfid(@Param("rfid") String  rfid);

    Integer batchSaveCustomerDevice(@Param("list") List<DeviceInfo> deviceInfos);

    Integer batchVcomLtDevice(@Param("list") List<DeviceInfo> deviceInfos);

    List<DeviceInfo> getDeviceByAll();
}
